package i_thread;

//=========================================================
// Applet
//---------------------------------------------------------
// 제 목 : Thread 사용하기2
// 작성자 : 박원기
// 작성일 : 2002
//========================================================= 
import java.awt.*;
import java.applet.*;

public class ThreadApplet extends Applet implements Runnable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	int i, sum;

	public void init() {
		resize(500, 500);
		setBackground(Color.white);
	}

	public void start() {
		Thread t = new Thread(this);
		t.start();
	}

	public void paint(Graphics g) {
		g.drawString("sum=" + sum, 40, i);
	}

	public void draw(int i) {
		Graphics g = getGraphics();
		sum = sum + 1;
		g.drawString("sum=" + sum, 40, i);
	}

	public void run() {
		for (i = 50; i < 400; i = i + 15) {
			// repaint();
			draw(i);
			try {
				Thread.sleep(500);
			} catch (InterruptedException e) {
			}
		}
	}
}